// 组件库全局引入
import Vue from 'vue'
const requireComponents = require.context('../components', true, /\.vue$/)

requireComponents.keys().forEach(keyPath => {
  const fileName = keyPath.split('/')[1]
  const componentConfig = requireComponents(`./${fileName}/index.vue`)
  const componentName = fileName
    .replace(/([A-Z])/g, '-$1')
    .toLowerCase()
    .replace(/-/, '') // 替换成连字符命名
  Vue.component(componentName, componentConfig.default || componentConfig) // 全局注册组件
})
